#include <iostream>
using namespace std;

/**
 * 
 * 时间复杂度：O(mn)
 * 空间复杂度：O(1)
 * 
 * 序列操作
 */
int main() {
    int a[110] = {};

    int n, m, k, x;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    while (m--) {
        int op;
        cin >> op;
        if (op == 1) {cin >> k;
            cout << a[k] << endl;
        } else if (op == 2) {
            cin >> k >> x;
            a[k] = x;
        } else {
            for (int i = 1; i <= n / 2; i++) {
                swap(a[i], a[n - i + 1]);
            }
        }
    }
    return 0;
}